package com.musicalevents.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.musicalevents.dao.BandDAO;
import com.musicalevents.dao.EventDAO;
import com.musicalevents.dao.PlaceDAO;
import com.musicalevents.dao.TownDAO;
import com.musicalevents.entity.Band;
import com.musicalevents.entity.Event;
import com.musicalevents.entity.Place;
import com.musicalevents.entity.Town;


@Service
public class BasicService {
	
	@Autowired
	private BandDAO bandDAO;
	@Autowired
	private TownDAO townDAO;
	@Autowired
	private PlaceDAO placeDAO;
	@Autowired
	private EventDAO eventDAO;
	
	@Transactional(readOnly = true)
	public List<Band> getAllBands() {
		List<Band> bands = bandDAO.getAll();
		return (bands);
	}
	
	@Transactional(readOnly = true)
	public List<Town> getAllTowns() {
		List<Town> towns = townDAO.getAll();
		return (towns);
	}
	
	@Transactional(readOnly = true)
	public List<Place> getAllPlaces() {
		List<Place> places = placeDAO.getAll();
		return (places);
	}
	
	@Transactional(readOnly = true)
	public List<Place> fetchAllPlacesLinkTown() {
		List<Place> places = placeDAO.fetchAllPlacesLinkTown();
		return (places);
	}
	
	@Transactional(readOnly = true)
	public List<Event> getAllEvents() {
		List<Event> events = eventDAO.getAll();
		return (events);
	}
	
	@Transactional(readOnly = true)
	public List<Event> fetchAllEventsLinkPlaceTown() {
		List<Event> events = eventDAO.fetchAllEventsLinkPlaceTown();
		return (events);
	}	
}
